package nc.ui.uif2.actions;

import java.awt.event.ActionEvent;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.UIState;
import nc.ui.uif2.editor.IEditor;
import nc.ui.uif2.model.AbstractAppModel;

public class CancelAction extends NCAction
{
  private static final long serialVersionUID = 5311551285937931557L;
  private AbstractAppModel model;
  private IEditor editor;

  public CancelAction()
  {
    ActionInitializer.initializeAction(this, 7);
  }
  public void doAction(ActionEvent e) {
    this.editor.setValue(this.model.getSelectedData());
    this.model.setUiState(UIState.NOT_EDIT);
  }

  protected boolean isActionEnable()
  {
    return (this.model.getUiState() == UIState.ADD) || (this.model.getUiState() == UIState.EDIT);
  }
  public AbstractAppModel getModel() {
    return this.model;
  }

  public void setModel(AbstractAppModel model) {
    this.model = model;
    model.addAppEventListener(this);
  }
  public IEditor getEditor() {
    return this.editor;
  }
  public void setEditor(IEditor editor) {
    this.editor = editor;
  }
}